

clear 
set scheme lean2, permanent
global pm = char(177)
set more off

gl date = c(current_date)
if c(os) == "MacOSX" gl user "/Users/`c(username)'"
else if c(os) == "Windows" gl user "C:\Users\\`c(username)'"
else if c(os) == "Unix" gl user "/usr/`c(username)'"
di "$user

set graphics on  
 
global path_data_processed "\data\processed"
global path_output "\data\output"

 
clear all
set more off

cd "$path_data_processed"
use "robustnessexperiment2.dta", clear

cd "$path_output"
 

loc experiments "prior_recession z_fin_prospects z_ndcons_index_A"


preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""




foreach choice in `experiments' {


***OLS


    qui reg `choice' demandtreatment anchoring, r
    sigstar demandtreatment, prec(3)
    estadd loc thisstat2 = "`r(bstar)'": col`colnum'
    estadd loc thisstat3 = "`r(sestar)'": col`colnum'
	
 sigstar anchoring, prec(3)
    estadd loc thisstat5 = "`r(bstar)'": col`colnum'
    estadd loc thisstat6 = "`r(sestar)'": col`colnum'
		
	
    estadd loc thisstat8 = `e(N)': col`colnum'

	
			
	loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"

}
	
loc rowlabels " " " "Demand Treatment" " " " " "Anchoring" " " " " "Observations" " "  "
loc rowstats ""

forval i = 1/8 {
    loc rowstats "`rowstats' thisstat`i'"
}

esttab * using "demandanchoring.tex", replace cells(none) booktabs nonotes nomtitles /*nonum*/ compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
  mgroups("\shortstack{Probability of\\a recession\\(percent)}" "\shortstack{Household\\financial\\prospects}" "\shortstack{Consumption\\growth\\(planned)}", pattern(1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

	
	
	
	
	eststo clear	




















